Xojo Conferences
XDCMay2019MiamiUSA

Platforms to show: All Mac Windows Linux Cross-Platform

ATSFontActivateFileMBS(File as FolderItem, OnlyLocal as boolean, Options as Integer, byref FontHandle as Integer) as Integer
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
global method Apple Type Services for Fonts MBS MacCF Plugin 5.3 Yes No No No No
Function: Activates one or more fonts from a file specification.
Example:
dim f as FolderItem = SpecialFolder.Desktop.Child("Firecat.ttf")
dim FontHandle as Integer
dim e as Integer = ATSFontActivateFileMBS(f, true, 0, FontHandle)

Break // on success e = 0 and FontHandle > 0
Notes:
You can use the function ATSFontActivateFileMBS to activate one font or more fonts. Activating a font makes that font available for use either locally (available only to your application) or globally (available to all applications on the system). A font's availability—local or global—is referred to as its context.

file:
A folderitem that specifies the name and location of a file or directory that contains the font data you want to activate.

OnlyLocal:
A value that specifies the context of the activated font. If you want the activated font to be accessible only from your application use the kATSFontContextLocal constant (=true). If you want the activated font to be accessible to all applications use the constant kATSFontContextGlobal (=false).

options:
An options flag. Pass kATSOptionFlagsDefault (=0) unless the font's data fork contains resource-fork information, you need to activate a directory of font directories, or you plan to call this function a number of time. If the font's data fork contains resource-fork information, pass the option kATSOptionFlagsUseDataForkAsResourceFork (=256). If the you want to activate a font directory that contains font directories, you must pass the option kATSOptionFlagsProcessSubdirectories (=64). If you plan to call this function a number of times, you can set the iOptions parameter to kATSOptionFlagsDoNotNotify (=128) set. When you are done activating fonts you can call the function ATSFontNotifyMBS with the action parameter set to kATSFontNotifyActionFontsChanged (=1). Then ATS notifies all applications who subscribe to notifications of the changes you made.

FontHandle:
On output, a reference to the font container that is activated from the file specification. You need this reference when you deactivate the font by calling the function ATSFontDeactivateMBS.

Requires Mac OS X 10.0 or newer.
Returns a Mac OS error code (0 for success).

Feedback, Comments & Corrections

ATSFontActivateStringMBS(FontData as string, OnlyLocal as boolean, Options as Integer, byref FontHandle as Integer) as Integer
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
global method Apple Type Services for Fonts MBS MacCF Plugin 5.3 Yes No No No No
Function: Activates one or more fonts at the specified location in memory.
Example:
dim f as FolderItem = SpecialFolder.Desktop.Child("some font file.ttf")
dim b as BinaryStream = BinaryStream.Open(f)
dim s as string = b.Read(b.Length)
dim FontHandle as Integer
dim e as Integer = ATSFontActivateStringMBS(S, true, 0, FontHandle)

Break // on success e = 0 and FontHandle > 0
Notes:
FontData:
The binary data of the font you want to activate.

OnlyLocal:
A value that specifies the context of the activated font. If you want the activated font to be accessible only from your application use the kATSFontContextLocal (=true) constant. If you want the activated font to be accessible to all applications use the constant kATSFontContextGlobal (=False).

options:
An ATSOptionFlags value. This parameter is currently reserved for future use, so you should pass kATSOptionFlagsDefault (=0).

FontHandle:
On output, a pointer to a font container reference that refers to the file that contains the activated font data.

You use this function to activate a streamed font, such as a font contained in a PDF file. Your application must first load the font data into a string and pass it to the ATSFontActivateStringMBS function.

Requires Mac OS X 10.0 or newer.
Returns a Mac OS error code (0 for success).

Feedback, Comments & Corrections

ATSFontCountMBS as Integer
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
global method Apple Type Services for Fonts MBS MacCF Plugin 4.0 Yes No No No No
Function: Returns the number of installed fonts.
Notes:
Returns 0 on any error.
Value may change when the user installs or removes fonts while the application is working.

Feedback, Comments & Corrections

ATSFontDeactivateMBS(FontHandle as Integer, Options as Integer) as Integer
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
global method Apple Type Services for Fonts MBS MacCF Plugin 5.3 Yes No No No No
Function: Deactivates one or more fonts.
Notes:
FontHandle:
The handle value you got from ATSFontActivateFileMBS or ATSFontActivateStringMBS.

options:
You should pass kATSOptionFlagsDefault (=0) unless to plan to call this function a number of times to deactivate many fonts. If you plan to call this function a number of times, you can set the iOptions parameter to kATSOptionFlagsDoNotNotify (=128) set. When you are done deactivating fonts you can call the function ATSFontNotifyMBS with the action parameter set to kATSFontNotifyActionFontsChanged (=1). ATS notifies all applications who subscribe to notifications of the changes you made.

When you deactivate a font, you must supply the font handle you obtained when you activated the font. You can't deactivate a font that you did not activate by calling the functions ATSFontActivateFileMBS or ATSFontActivateStringMBS.

You should use caution if you deactivate a font that is available globally, as its deactivation impacts any application that uses that font.

Requires Mac OS X 10.0 or newer.

Feedback, Comments & Corrections

ATSFontFamilyFindFromNameMBS(name as String) as ATSFontFamilyMBS
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
global method Apple Type Services for Fonts MBS MacCF Plugin 3.4 Yes No No No No
Function: Returns the font family which matches the given name.
Example:
// query postscript names for a font
const nameOfAFont = "Arial"

dim ATSFontName as string
dim ATSFontFamilyName as string
dim ATSFontPostscriptName as string
dim ATSFontPostscriptNameBold as string
dim ATSFontPostscriptNameItalic as string

dim f as ATSFontMBS
dim ATSFontFamily as ATSFontFamilyMBS = ATSFontFamilyFindFromNameMBS(nameOfAFont)
if ATSFontFamily <> nil then
ATSFontFamilyName = ATSFontFamily.Name
const normal = 0
const bold = 1
const italic = 2
const underline = 4
const outline = 8
const shadow = &h10
const condense = &h20
const extend = &h40

f = ATSFontFamily.Font(normal)
if f <> nil then
ATSFontName = f.Name
ATSFontPostscriptName = f.PostscriptName
end if

f=ATSFontFamily.Font(bold)

if f <> nil then
ATSFontPostscriptNameBold = f.PostscriptName
end if

f = ATSFontFamily.Font(italic)

if f <> nil then
ATSFontPostscriptNameItalic = f.PostscriptName
end if

end if

Break // read names in debugger
Notes: Returns nil on any error.

Some examples using this method:

Feedback, Comments & Corrections

ATSFontFamilyFindFromQuickDrawNameMBS(qdname as string) as ATSFontFamilyMBS
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
global method Apple Type Services for Fonts MBS MacCF Plugin 3.4 Yes No No No No
Function: Returns the font family which matches the given quickdraw name.
Notes:
Returns nil on any error.
The name must be encoded in MacRoman.

Feedback, Comments & Corrections

ATSFontFindFromContainerMBS(FontContainerHandle as Integer) as ATSFontMBS()
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
global method Apple Type Services for Fonts MBS MacCF Plugin 16.2 Yes No No No No
Function: Finds fonts in a font container.
Example:
// activate a font
dim f as FolderItem = GetFolderItem("Gadget")
dim FontContainerHandle as Integer
dim e as Integer = ATSFontActivateFileMBS(f, false, 0, FontContainerHandle)

if e = 0 then
// find fonts
dim fonts() as atsFontMBS = ATSFontFindFromContainerMBS(FontContainerHandle)

dim names() as string

for each font as atsFontMBS in fonts
names.Append font.PostscriptName + " - " + font.Name
next

// show names
MsgBox Join(names,EndOfLine)
end if
Notes: You activate a font and this function queries all the fonts in the font container.

Blog Entries

Feedback, Comments & Corrections

ATSFontFindFromNameMBS(name as String) as ATSFontMBS
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
global method Apple Type Services for Fonts MBS MacCF Plugin 3.4 Yes No No No No
Function: Returns the font matching the given name.
Notes: Returns nil on any error.

Feedback, Comments & Corrections

ATSFontFindFromPostScriptNameMBS(name as String) as ATSFontMBS
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
global method Apple Type Services for Fonts MBS MacCF Plugin 3.4 Yes No No No No
Function: Returns the font matching the given name.
Notes: Returns nil on any error.

Feedback, Comments & Corrections

ATSFontGenerationMBS as Integer
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
global method Apple Type Services for Fonts MBS MacCF Plugin 3.4 Yes No No No No
Function: The current font generation counter value.
Notes:
If somewhere on the system something changes, this counter is updated.
(You may need to update your font list if this counter changes)

Feedback, Comments & Corrections

ATSFontNotifyMBS(Action as Integer) as Integer
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
global method Apple Type Services for Fonts MBS MacCF Plugin 5.3 Yes No No No No
Function: Notifies the ATS Server about font changes.
Notes:
The following is a list of actions you might wish the ATS server to perform and notify clients if appropriate.

kATSFontNotifyActionFontsChanged = 1
Used after a batch (de)activation of fonts occurs. Typically the caller has exercised multiple global (De)Activation calls with the kATSOptionFlagsDoNotNotify set. Once all calls are completed, one may use ATSFontNotify with this action to ask ATS to notify all clients.

kATSFontNotifyActionDirectoriesChanged = 2
The ATS system with the help of the Finder keeps track of changes to any of the font directories in the system domains ( System, Local, Network, User, & Classic). However, one may wish to add/remove fonts to these locations programmatically. This action is used to let ATS server to rescan these directories and post notifications if necessary.

Requires Mac OS X 10.2 to work.
Returns -1 if function is not present on the Mac or else a Mac OS error code.
(0 for success)

Feedback, Comments & Corrections

ATSUFindFontFromNameMBS(name as string, code as Integer, platform as Integer, script as Integer, language as Integer) as Integer
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
global method Apple Type Services for Fonts MBS MacCF Plugin 4.2 Yes No No No No
Function: Find a font by name.
Example:
const kFontFullName=4
const kFontNoPlatform =-1
const kFontNoScript=-1
const kFontNoLanguag=-1

msgbox str(ATSUFindFontFromNameMBS("Times Roman",kFontFullName,kFontNoPlatform, kFontNoScript, kFontNoLanguag))
Notes:
Returns the font ID for the given font or 0 on any error.

Some more constants:
kFontCopyrightName = 0
kFontFamilyName = 1
kFontStyleName = 2
kFontUniqueName = 3
kFontFullName = 4
kFontVersionName = 5
kFontPostscriptName = 6
kFontTrademarkName = 7
kFontManufacturerName = 8
kFontDesignerName = 9
kFontDescriptionName = 10
kFontVendorURLName = 11
kFontDesignerURLName = 12
kFontLicenseDescriptionName = 13
kFontLicenseInfoURLName = 14
kFontLastReservedName = 255

Some examples using this method:

Feedback, Comments & Corrections

ATSUFindFontNameMBS(FontID as Integer, code as Integer, platform as Integer, script as Integer, language as Integer) as string
Type Topic Plugin Version macOS Windows Linux Console & Web iOS
global method Apple Type Services for Fonts MBS MacCF Plugin 5.3 Yes No No No No
Function: Obtains a name string for the first font in a name table that matches the specified ATSUI font ID, name code, platform, script, and/or language.
Example:
const kFontUnicodePlatform=0
const kFontMacintoshPlatform=1

const kFontRomanScript=0

const kFontEnglishLanguage=0

const kFontFamilyName=1
const kFontUniqueName=3
const kFontFullName=4
const kFontPostscriptName=6

const kFontNoPlatformCode=-1
const kFontNoScriptCode=-1
const kFontNoLanguageCode=-1

dim a as ATSFontListMBS
dim fontid as Integer

a=new ATSFontListMBS

fontid=a.FontID(0)

msgbox ATSUFindFontNameMBS(fontid,kFontPostscriptName,kFontNoPlatformCode,kFontNoScriptCode,kFontNoLanguageCode)
Notes:
To obtain an ATSUI font ID for the first font in a name table that matches the specified name string, name code, platform, script, and/or language, call the function ATSUFindFontFromNameMBS.

To obtain the font name string, name code, platform, script, and language for the font that matches an ATSUI font ID and name table index, use the ATSFontListMBS class.

Returns a Mac OS error code.

Parameters:

FontID:
The font for which to obtain a name string. Note that because Apple Type Services assigns ATSUFontID values systemwide at runtime, font IDs can change across system restarts.

Code:
A constant specifying the FontNameCode value of the font for which to obtain a name string.

Platform:
A constant specifying the encoding of the font. If you pass the kFontNoPlatformCode constant, ATSUFindFontName produces the first font in the name table matching the other specified parameters.

Script:
A constant specifying the script of the font.
If you pass the kFontNoScriptCode constant, ATSUFindFontName produces the first font in the name table matching the other specified parameters.

Language:
A constant specifying the language of the font you are searching for.

Available on Mac OS 8.5 and newer.

The following are special "don't care" values to be used in interfaces

kFontNoPlatformCode-1
kFontNoScriptCode-1
kFontNoLanguageCode-1

Language codes are zero based everywhere but within a 'cmap' table
kFontEnglishLanguage = 0
kFontFrenchLanguage = 1
kFontGermanLanguage = 2
kFontItalianLanguage = 3
kFontDutchLanguage = 4
kFontSwedishLanguage = 5
kFontSpanishLanguage = 6
kFontDanishLanguage = 7
kFontPortugueseLanguage = 8
kFontNorwegianLanguage = 9
kFontHebrewLanguage = 10
kFontJapaneseLanguage = 11
kFontArabicLanguage = 12
kFontFinnishLanguage = 13
kFontGreekLanguage = 14
kFontIcelandicLanguage = 15
kFontMalteseLanguage = 16
kFontTurkishLanguage = 17
kFontCroatianLanguage = 18
kFontTradChineseLanguage = 19
kFontUrduLanguage = 20
kFontHindiLanguage = 21
kFontThaiLanguage = 22
kFontKoreanLanguage = 23
kFontLithuanianLanguage = 24
kFontPolishLanguage = 25
kFontHungarianLanguage = 26
kFontEstonianLanguage = 27
kFontLettishLanguage = 28
kFontLatvianLanguage = kFontLettishLanguage
kFontSaamiskLanguage = 29
kFontLappishLanguage = kFontSaamiskLanguage
kFontFaeroeseLanguage = 30
kFontFarsiLanguage = 31
kFontPersianLanguage = kFontFarsiLanguage
kFontRussianLanguage = 32
kFontSimpChineseLanguage = 33
kFontFlemishLanguage = 34
kFontIrishLanguage = 35
kFontAlbanianLanguage = 36
kFontRomanianLanguage = 37
kFontCzechLanguage = 38
kFontSlovakLanguage = 39
kFontSlovenianLanguage = 40
kFontYiddishLanguage = 41
kFontSerbianLanguage = 42
kFontMacedonianLanguage = 43
kFontBulgarianLanguage = 44
kFontUkrainianLanguage = 45
kFontByelorussianLanguage = 46
kFontUzbekLanguage = 47
kFontKazakhLanguage = 48
kFontAzerbaijaniLanguage = 49
kFontAzerbaijanArLanguage = 50
kFontArmenianLanguage = 51
kFontGeorgianLanguage = 52
kFontMoldavianLanguage = 53
kFontKirghizLanguage = 54
kFontTajikiLanguage = 55
kFontTurkmenLanguage = 56
kFontMongolianLanguage = 57
kFontMongolianCyrLanguage = 58
kFontPashtoLanguage = 59
kFontKurdishLanguage = 60
kFontKashmiriLanguage = 61
kFontSindhiLanguage = 62
kFontTibetanLanguage = 63
kFontNepaliLanguage = 64
kFontSanskritLanguage = 65
kFontMarathiLanguage = 66
kFontBengaliLanguage = 67
kFontAssameseLanguage = 68
kFontGujaratiLanguage = 69
kFontPunjabiLanguage = 70
kFontOriyaLanguage = 71
kFontMalayalamLanguage = 72
kFontKannadaLanguage = 73
kFontTamilLanguage = 74
kFontTeluguLanguage = 75
kFontSinhaleseLanguage = 76
kFontBurmeseLanguage = 77
kFontKhmerLanguage = 78
kFontLaoLanguage = 79
kFontVietnameseLanguage = 80
kFontIndonesianLanguage = 81
kFontTagalogLanguage = 82
kFontMalayRomanLanguage = 83
kFontMalayArabicLanguage = 84
kFontAmharicLanguage = 85
kFontTigrinyaLanguage = 86
kFontGallaLanguage = 87
kFontOromoLanguage = kFontGallaLanguage
kFontSomaliLanguage = 88
kFontSwahiliLanguage = 89
kFontRuandaLanguage = 90
kFontRundiLanguage = 91
kFontChewaLanguage = 92
kFontMalagasyLanguage = 93
kFontEsperantoLanguage = 94
kFontWelshLanguage = 128
kFontBasqueLanguage = 129
kFontCatalanLanguage = 130
kFontLatinLanguage = 131
kFontQuechuaLanguage = 132
kFontGuaraniLanguage = 133
kFontAymaraLanguage = 134
kFontTatarLanguage = 135
kFontUighurLanguage = 136
kFontDzongkhaLanguage = 137
kFontJavaneseRomLanguage = 138
kFontSundaneseRomLanguage = 139

kFontRomanScript = 0
kFontJapaneseScript = 1
kFontTraditionalChineseScript = 2
kFontChineseScript = kFontTraditionalChineseScript
kFontKoreanScript = 3
kFontArabicScript = 4
kFontHebrewScript = 5
kFontGreekScript = 6
kFontCyrillicScript = 7
kFontRussian = kFontCyrillicScript
kFontRSymbolScript = 8
kFontDevanagariScript = 9
kFontGurmukhiScript = 10
kFontGujaratiScript = 11
kFontOriyaScript = 12
kFontBengaliScript = 13
kFontTamilScript = 14
kFontTeluguScript = 15
kFontKannadaScript = 16
kFontMalayalamScript = 17
kFontSinhaleseScript = 18
kFontBurmeseScript = 19
kFontKhmerScript = 20
kFontThaiScript = 21
kFontLaotianScript = 22
kFontGeorgianScript = 23
kFontArmenianScript = 24
kFontSimpleChineseScript = 25
kFontTibetanScript = 26
kFontMongolianScript = 27
kFontGeezScript = 28
kFontEthiopicScript = kFontGeezScript
kFontAmharicScript = kFontGeezScript
kFontSlavicScript = 29
kFontEastEuropeanRomanScript = kFontSlavicScript
kFontVietnameseScript = 30
kFontExtendedArabicScript = 31
kFontSindhiScript = kFontExtendedArabicScript
kFontUninterpretedScript = 32

kFontUnicodePlatform = 0
kFontMacintoshPlatform = 1
kFontReservedPlatform = 2
kFontMicrosoftPlatform = 3
kFontCustomPlatform = 4

kFontCopyrightName = 0
kFontFamilyName = 1
kFontStyleName = 2
kFontUniqueName = 3
kFontFullName = 4
kFontVersionName = 5
kFontPostscriptName = 6
kFontTrademarkName = 7
kFontManufacturerName = 8
kFontDesignerName = 9
kFontDescriptionName = 10
kFontVendorURLName = 11
kFontDesignerURLName = 12
kFontLicenseDescriptionName = 13
kFontLicenseInfoURLName = 14
kFontLastReservedName = 255

Feedback, Comments & Corrections

The items on this page are in the following plugins: MBS MacCF Plugin.




Links
MBS Xojo PDF Plugins