Class FontMap
- All Implemented Interfaces:
Iterable<FontFamily>, Collection<FontFamily>, List<FontFamily>, SequencedCollection<FontFamily>, ListModel<FontFamily>, Proxy, ListModelJavaList<FontFamily>
- Direct Known Subclasses:
FontMap.FontMap$Impl, FontMap.FontMap$Impl
A PangoFontMap represents the set of fonts available for a
particular rendering system.
This is a virtual object with implementations being specific to particular rendering systems.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classFontMap.Builder<B extends FontMap.Builder<B>>Inner class implementing a builder pattern to construct a GObject with properties.static classThe FontMap$Impl type represents a native instance of the abstract FontMap class.static classThePangoFontMapClassstructure holds the virtual functions for a particularPangoFontMapimplementation.Nested classes/interfaces inherited from class GObject
GObject.NotifyCallback, GObject.ObjectClassNested classes/interfaces inherited from interface ListModel
ListModel.ItemsChangedCallback, ListModel.ListModel$Impl, ListModel.ListModelInterfaceNested classes/interfaces inherited from interface ListModelJavaList
ListModelJavaList.SubList<E,List> -
Constructor Summary
ConstructorsConstructorDescriptionFontMap()Create a new FontMap.FontMap(MemorySegment address) Create a FontMap instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionbooleanaddFontFile(String filename) Loads a font file with one or more fonts into thePangoFontMap.protected FontMapasParent()Return this instance as if it were its parent type.voidchanged()Forces a change in the fontmap, which will cause anyPangoContextusing this fontmap to change.Creates aPangoContextconnected tofontmap.protected FontFace@Nullable FontFamilyGets a font family by name.static MemoryLayoutThe memory layout of the native struct.intReturns the current serial number offontmap.static @Nullable TypegetType()Get the GType of the FontMap class.voidlistFamilies(@Nullable Out<FontFamily[]> families) List all families for a fontmap.@Nullable FontloadFont(Context context, FontDescription desc) Load the font in the fontmap that is the closest match fordesc.@Nullable FontsetloadFontset(Context context, FontDescription desc, Language language) Load a set of fonts in the fontmap that can be used to render a font matchingdesc.reloadFont(Font font, double scale, @Nullable Context context, @Nullable String variations) Returns a new font that is likefont,except that it is scaled byscale,its backend-dependent configuration (e.g. cairo font options) is replaced by the one incontext,and its variations are replaced byvariations.Methods inherited from class GObject
addToggleRef, addWeakPointer, bindProperty, bindProperty, bindProperty, bindPropertyFull, bindPropertyFull, bindPropertyWithClosures, bindPropertyWithClosures, builder, compatControl, connect, connect, connect, constructed, disconnect, dispatchPropertiesChanged, dispose, dupData, dupQdata, emit, emitNotify, finalize_, forceFloating, freezeNotify, get, getData, getProperty, getProperty, getProperty, getQdata, getv, interfaceFindProperty, interfaceInstallProperty, interfaceListProperties, isFloating, newInstance, newInstance, newv, notify, notify, notifyByPspec, onNotify, ref, refSink, removeToggleRef, removeWeakPointer, replaceData, replaceQdata, runDispose, set, setData, setDataFull, setProperty, setProperty, setProperty, setQdata, setQdataFull, setv, stealData, stealQdata, takeRef, thawNotify, unref, watchClosure, weakRef, weakUnref, withPropertiesMethods inherited from class TypeInstance
callParent, callParent, cast, getPrivate, readGClass, writeGClassMethods inherited from class ProxyInstance
equals, handle, hashCodeMethods inherited from class Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Collection
parallelStream, removeIf, stream, toArrayMethods inherited from interface List
addFirst, addLast, equals, getFirst, getLast, hashCode, removeFirst, removeLast, replaceAll, reversed, sort, spliteratorMethods inherited from interface ListModel
emitItemsChanged, getItem, getItemType, getNItems, itemsChanged, onItemsChangedMethods inherited from interface ListModelJavaList
add, add, addAll, addAll, clear, contains, containsAll, get, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, retainAll, set, size, subList, toArray, toArray
-
Constructor Details
-
FontMap
Create a FontMap instance for the provided memory address.- Parameters:
address- the memory address of the native object
-
FontMap
public FontMap()Create a new FontMap.
-
-
Method Details
-
getType
-
getMemoryLayout
The memory layout of the native struct.- Returns:
- the memory layout
-
asParent
-
addFontFile
Loads a font file with one or more fonts into the
PangoFontMap.The added fonts will take precedence over preexisting fonts with the same name.
- Parameters:
filename- Path to the font file- Returns:
- True if the font file is successfully loaded into the fontmap, false if an error occurred.
- Throws:
GErrorException- seeGError- Since:
- 1.56
-
changed
public void changed()Forces a change in the fontmap, which will cause any
PangoContextusing this fontmap to change.This function is only useful when implementing a new backend for Pango, something applications won't do. Backends should call this function if they have attached extra data to the fontmap and such data is changed.
- Since:
- 1.34
-
createContext
Creates a
PangoContextconnected tofontmap.This is equivalent to
Context()followed byContext.setFontMap(FontMap).If you are using Pango as part of a higher-level system, that system may have it's own way of create a
PangoContext. For instance, the GTK toolkit has, among others, gtk_widget_get_pango_context(). Use those instead.- Returns:
- the newly allocated
PangoContext, which should be freed with g_object_unref(). - Since:
- 1.22
-
getFamily
Gets a font family by name.- Parameters:
name- a family name- Returns:
- the
PangoFontFamily - Since:
- 1.46
-
getSerial
public int getSerial()Returns the current serial number of
fontmap.The serial number is initialized to an small number larger than zero when a new fontmap is created and is increased whenever the fontmap is changed. It may wrap, but will never have the value 0. Since it can wrap, never compare it with "less than", always use "not equals".
The fontmap can only be changed using backend-specific API, like changing fontmap resolution.
This can be used to automatically detect changes to a
PangoFontMap, like inPangoContext.- Returns:
- The current serial number of
fontmap. - Since:
- 1.32.4
-
listFamilies
List all families for a fontmap.
Note that the returned families are not in any particular order.
PangoFontMapalso implemented theListModelinterface for enumerating families.- Parameters:
families- location to store a pointer to an array ofPangoFontFamily*. This array should be freed with g_free().
-
loadFont
Load the font in the fontmap that is the closest match fordesc.- Parameters:
context- thePangoContextthe font will be used withdesc- aPangoFontDescriptiondescribing the font to load- Returns:
- the newly allocated
PangoFontloaded, ornullif no font matched.
-
loadFontset
Load a set of fonts in the fontmap that can be used to render a font matchingdesc.- Parameters:
context- thePangoContextthe font will be used withdesc- aPangoFontDescriptiondescribing the font to loadlanguage- aPangoLanguagethe fonts will be used for- Returns:
- the newly allocated
PangoFontsetloaded, ornullif no font matched.
-
reloadFont
public Font reloadFont(Font font, double scale, @Nullable Context context, @Nullable String variations) Returns a new font that is like
font,except that it is scaled byscale,its backend-dependent configuration (e.g. cairo font options) is replaced by the one incontext,and its variations are replaced byvariations.Note that the scaling here is meant to be linear, so this scaling can be used to render a font on a hi-dpi display without changing its optical size.
- Parameters:
font- a font in this FontMapscale- the scale factor to applycontext- aPangoContextvariations- font variations to use- Returns:
- the modified font
- Since:
- 1.52
-
getFace
-