Dependencies
import {
"Milky2018/moon_swash" @swash,
"Milky2018/moon_swash/shape" @swash_shape,
"Milky2018/moon_swash/scale" @swash_scale,
}import {
"Milky2018/moon_swash/iter" @swash_iter,
"Milky2018/moon_swash/proxy" @swash_proxy,
}let data : Bytes = ...
let font = @swash.FontRef::from_offset(data, 0).unwrap()let cx = @swash_shape.ShapeContext::new()
let shaper = cx.builder(font).size(14.0).build()
shaper.add_str("Hello, world!")
shaper.shape_with(fn(cluster) {
// cluster.glyphs() / cluster.source() ...
cluster |> ignore
})let gid = font.charmap().map(('Q').to_int().reinterpret_as_uint())
let scx = @swash_scale.ScaleContext::new()
let scaler = scx.builder(font).size(14.0).hint(true).build()
let render = @swash_scale.Render::new([@swash_scale.Source::Outline])
let img = render.render(scaler, gid).unwrap()
// Zero-copy pixel access:
let pixels = img.data_view()
pixels |> ignore
// GPU-friendly RGBA8 (premultiplied):
let white = [(255).to_byte(), (255).to_byte(), (255).to_byte(), (255).to_byte()]
img.to_rgba8(white) |> ignore
let rgba8 = img.data_view()
rgba8 |> ignoretype NormalizedCoord = Inttype UserData = UIntpub(open) trait Codepoint {
fn properties(Self) -> Properties
fn opening_bracket(Self) -> Char?
fn closing_bracket(Self) -> Char?
fn mirror(Self) -> Char?
fn bracket_type(Self) -> BracketType
fn decompose(Self) -> Iter[Char]
fn decompose_compatible(Self) -> Iter[Char]
}fn closing_bracket(self : Char) -> Char?fn mirror(self : Char) -> Char?fn opening_bracket(self : Char) -> Char?pub(open) trait TableProvider {
fn table_by_tag(Self, tag : UInt) -> BytesView?
}pub(all) enum Action {
Substitution
Attachment
Adjustment
}pub struct Attributes {
value : UInt
}
fn Attributes::Attributes(stretch : Stretch, weight : Weight, style : Style) -> Attributesimpl Eq for Attributesimpl Show for Attributespub(all) enum BidiClass {
AL
AN
B
BN
CS
EN
ES
ET
FSI
L
LRE
LRI
LRO
NSM
ON
PDF
PDI
R
RLE
RLI
RLO
S
WS
}pub struct BitmapStrike {
b : BeBytes
bitmap_data : BytesView
offset : Int
upem : UInt
is_sbix : Bool
is_apple : Bool
}pub struct BitmapStrikes {
b : BeBytes
bitmap_data : BytesView
is_sbix : Bool
is_apple : Bool
upem : UInt
len : Int
}fn BitmapStrikes::find_by_exact_ppem(self : BitmapStrikes, ppem : UInt16, glyph_id : UInt16) -> BitmapStrike?fn BitmapStrikes::find_by_nearest_ppem(self : BitmapStrikes, ppem : UInt16, glyph_id : UInt16) -> BitmapStrike?pub struct BitmapStrikesProxy {
bitmaps : (UInt, UInt)
color_bitmaps : (UInt, UInt)
upem : UInt
is_apple : Bool
}fn BitmapStrikesProxy::materialize_alpha(self : BitmapStrikesProxy, font : FontRef) -> BitmapStrikesfn BitmapStrikesProxy::materialize_color(self : BitmapStrikesProxy, font : FontRef) -> BitmapStrikespub(all) enum Block {
Adlam
AegeanNumbers
Ahom
AlchemicalSymbols
AlphabeticPresentationForms
AnatolianHieroglyphs
AncientGreekMusicalNotation
AncientGreekNumbers
AncientSymbols
Arabic
ArabicExtendedA
ArabicMathematicalAlphabeticSymbols
ArabicPresentationFormsA
ArabicPresentationFormsB
ArabicSupplement
Armenian
Arrows
BasicLatin
Avestan
Balinese
Bamum
BamumSupplement
BassaVah
Batak
Bengali
Bhaiksuki
BlockElements
Bopomofo
BopomofoExtended
BoxDrawing
Brahmi
BraillePatterns
Buginese
Buhid
ByzantineMusicalSymbols
Carian
CaucasianAlbanian
Chakma
Cham
Cherokee
CherokeeSupplement
ChessSymbols
Chorasmian
CJKUnifiedIdeographs
CJKCompatibility
CJKCompatibilityForms
CJKCompatibilityIdeographs
CJKCompatibilityIdeographsSupplement
CJKUnifiedIdeographsExtensionA
CJKUnifiedIdeographsExtensionB
CJKUnifiedIdeographsExtensionC
CJKUnifiedIdeographsExtensionD
CJKUnifiedIdeographsExtensionE
CJKUnifiedIdeographsExtensionF
CJKUnifiedIdeographsExtensionG
CJKRadicalsSupplement
CJKStrokes
HangulCompatibilityJamo
ControlPictures
Coptic
CopticEpactNumbers
CountingRodNumerals
Cuneiform
CurrencySymbols
CypriotSyllabary
Cyrillic
CyrillicExtendedA
CyrillicExtendedB
CyrillicExtendedC
CyrillicSupplement
Deseret
Devanagari
DevanagariExtended
CombiningDiacriticalMarks
CombiningDiacriticalMarksExtended
CombiningDiacriticalMarksSupplement
Dingbats
DivesAkuru
Dogra
DominoTiles
Duployan
EarlyDynasticCuneiform
EgyptianHieroglyphFormatControls
EgyptianHieroglyphs
Elbasan
Elymaic
Emoticons
EnclosedAlphanumerics
EnclosedAlphanumericSupplement
EnclosedIdeographicSupplement
Ethiopic
EthiopicExtended
EthiopicExtendedA
EthiopicSupplement
GeometricShapes
GeometricShapesExtended
Georgian
GeorgianExtended
GeorgianSupplement
Glagolitic
GlagoliticSupplement
Gothic
Grantha
GreekExtended
Gujarati
GunjalaGondi
Gurmukhi
CombiningHalfMarks
HangulSyllables
HanifiRohingya
Hanunoo
Hatran
Hebrew
HighPrivateUseSurrogates
HighSurrogates
Hiragana
IdeographicDescriptionCharacters
ImperialAramaic
CommonIndicNumberForms
IndicSiyaqNumbers
InscriptionalPahlavi
InscriptionalParthian
IPAExtensions
HangulJamo
HangulJamoExtendedA
HangulJamoExtendedB
Javanese
Kaithi
KanaExtendedA
KanaSupplement
Kanbun
KangxiRadicals
Kannada
Katakana
KatakanaPhoneticExtensions
KayahLi
Kharoshthi
KhitanSmallScript
Khmer
KhmerSymbols
Khojki
Khudawadi
Lao
Latin1Supplement
LatinExtendedA
LatinExtendedAdditional
LatinExtendedB
LatinExtendedC
LatinExtendedD
LatinExtendedE
Lepcha
LetterlikeSymbols
Limbu
LinearA
LinearBIdeograms
LinearBSyllabary
Lisu
LisuSupplement
LowSurrogates
Lycian
Lydian
Mahajani
MahjongTiles
Makasar
Malayalam
Mandaic
Manichaean
Marchen
MasaramGondi
MathematicalAlphanumericSymbols
MathematicalOperators
MayanNumerals
Medefaidrin
MeeteiMayek
MeeteiMayekExtensions
MendeKikakui
MeroiticCursive
MeroiticHieroglyphs
Miao
MiscellaneousMathematicalSymbolsA
MiscellaneousMathematicalSymbolsB
MiscellaneousSymbols
MiscellaneousTechnical
Modi
SpacingModifierLetters
ModifierToneLetters
Mongolian
MongolianSupplement
Mro
Multani
MusicalSymbols
Myanmar
MyanmarExtendedA
MyanmarExtendedB
Nabataean
Nandinagari
NoBlock
NewTaiLue
Newa
NKo
NumberForms
Nushu
NyiakengPuachueHmong
OpticalCharacterRecognition
Ogham
OlChiki
OldHungarian
OldItalic
OldNorthArabian
OldPermic
OldPersian
OldSogdian
OldSouthArabian
OldTurkic
Oriya
OrnamentalDingbats
Osage
Osmanya
OttomanSiyaqNumbers
PahawhHmong
Palmyrene
PauCinHau
PhaistosDisc
Phoenician
PhoneticExtensions
PhoneticExtensionsSupplement
PlayingCards
PsalterPahlavi
PrivateUseArea
GeneralPunctuation
Rejang
RumiNumeralSymbols
Runic
Samaritan
Saurashtra
Sharada
Shavian
ShorthandFormatControls
Siddham
Sinhala
SinhalaArchaicNumbers
SmallFormVariants
SmallKanaExtension
Sogdian
SoraSompeng
Soyombo
Specials
Sundanese
SundaneseSupplement
SupplementalArrowsA
SupplementalArrowsB
SupplementalArrowsC
SupplementalMathematicalOperators
SupplementaryPrivateUseAreaA
SupplementaryPrivateUseAreaB
SupplementalPunctuation
SuttonSignWriting
SylotiNagri
Syriac
SyriacSupplement
Tagalog
Tagbanwa
Tags
TaiLe
TaiTham
TaiViet
TaiXuanJingSymbols
Takri
Tamil
TamilSupplement
Tangut
TangutComponents
TangutSupplement
Telugu
Thaana
Thai
Tibetan
Tifinagh
Tirhuta
UnifiedCanadianAboriginalSyllabics
UnifiedCanadianAboriginalSyllabicsExtended
Ugaritic
Vai
VedicExtensions
VerticalForms
VariationSelectors
VariationSelectorsSupplement
Wancho
WarangCiti
Yezidi
YiRadicals
YiSyllables
YijingHexagramSymbols
ZanabazarSquare
GreekandCoptic
SuperscriptsandSubscripts
CombiningDiacriticalMarksforSymbols
MiscellaneousSymbolsandArrows
CJKSymbolsandPunctuation
EnclosedCJKLettersandMonths
Phagspa
HalfwidthandFullwidthForms
CuneiformNumbersandPunctuation
IdeographicSymbolsandPunctuation
MiscellaneousSymbolsandPictographs
TransportandMapSymbols
SupplementalSymbolsandPictographs
SymbolsandPictographsExtendedA
SymbolsforLegacyComputing
}pub(all) enum Boundary {
None
Word
Line
Mandatory
}pub(all) enum Category {
Other
Control
Format
Unassigned
PrivateUse
Surrogate
Letter
CasedLetter
LowercaseLetter
ModifierLetter
OtherLetter
TitlecaseLetter
UppercaseLetter
Mark
SpacingMark
EnclosingMark
NonspacingMark
Number
DecimalNumber
LetterNumber
OtherNumber
Punctuation
ConnectorPunctuation
DashPunctuation
ClosePunctuation
FinalPunctuation
InitialPunctuation
OtherPunctuation
OpenPunctuation
Symbol
CurrencySymbol
ModifierSymbol
MathSymbol
OtherSymbol
Separator
LineSeparator
ParagraphSeparator
SpaceSeparator
}pub struct CharInfo {
// private fields
}
fn CharInfo::CharInfo(properties : Properties, boundary : Boundary) -> CharInfopub struct CharmapProxy {
offset : UInt
format : UInt
symbol : Bool
}pub(all) enum Cjk {
None
Traditional
Simplified
Japanese
Korean
}pub struct ClusterChar {
// private fields
}
fn ClusterChar::ClusterChar(ch : Char, offset : UInt, shape_class : ShapeClass, joining_type : JoiningType, ignorable : Bool, contributes_to_shaping : Bool, glyph_id : UInt16, data : UInt) -> ClusterChartype ClusterInfopub(all) enum CombiningClass {
NotReordered
Overlay
HanReading
Nukta
KanaVoicing
Virama
Ccc10
Ccc11
Ccc12
Ccc13
Ccc14
Ccc15
Ccc16
Ccc17
Ccc18
Ccc19
Ccc20
Ccc21
Ccc22
Ccc23
Ccc24
Ccc25
Ccc26
Ccc27
Ccc28
Ccc29
Ccc30
Ccc31
Ccc32
Ccc33
Ccc34
Ccc35
Ccc36
Ccc84
Ccc91
Ccc103
Ccc107
Ccc118
Ccc122
Ccc129
Ccc130
Ccc132
Ccc133
AttachedBelowLeft
AttachedBelow
AttachedAbove
AttachedAboveRight
BelowLeft
Below
BelowRight
Left
Right
AboveLeft
Above
AboveRight
DoubleBelow
DoubleAbove
IotaSubscript
}pub(all) enum Encoding {
Unicode
MacRoman
Other(UInt16, UInt16)
}type Featuretype Featurespub struct FontDataRef {
data : Bytes
len : Int
}impl TableProvider for FontReftype GlyphMetricstype Instancetype Instancespub(all) enum LineBreak {
AI
AL
B2
BA
BB
BK
CB
CJ
CL
CM
CP
CR
EB
EM
EX
GL
H2
H3
HL
HY
ID
IN
IS
JL
JT
JV
LF
NL
NS
NU
OP
PO
PR
QU
RI
SA
SG
SP
SY
WJ
XX
ZW
ZWJ
}fn LocalizedStrings::find_by_id(self : LocalizedStrings, id : StringId, language : String?) -> LocalizedString?pub struct Metrics {
units_per_em : UInt16
glyph_count : UInt16
is_monospace : Bool
has_vertical_metrics : Bool
ascent : Double
descent : Double
leading : Double
vertical_ascent : Double
vertical_descent : Double
vertical_leading : Double
cap_height : Double
x_height : Double
average_width : Double
max_width : Double
underline_offset : Double
strikeout_offset : Double
stroke_size : Double
}type MetricsProxyfn MetricsProxy::materialize_glyph_metrics(self : MetricsProxy, font : FontRef, coords : ArrayView[Int]) -> GlyphMetricsfn MetricsProxy::materialize_metrics(self : MetricsProxy, font : FontRef, coords : ArrayView[Int]) -> Metricspub(all) enum MyanmarClass {
A
As
C
D
D0
DB
GB
H
IV
J
K
MH
MR
MW
MY
O
P
PT
R
S
V
VAbv
VBlw
VPre
VPst
VS
WJ
}pub struct ObliqueAngle {
value : UInt16
}pub struct Properties {
bits : UInt
}pub(all) enum Script {
Adlam
CaucasianAlbanian
Ahom
Arabic
ImperialAramaic
Armenian
Avestan
Balinese
Bamum
BassaVah
Batak
Bengali
Bhaiksuki
Bopomofo
Brahmi
Braille
Buginese
Buhid
Chakma
CanadianAboriginal
Carian
Cham
Cherokee
Chorasmian
Coptic
Cypriot
Cyrillic
Devanagari
DivesAkuru
Dogra
Deseret
Duployan
EgyptianHieroglyphs
Elbasan
Elymaic
Ethiopic
Georgian
Glagolitic
GunjalaGondi
MasaramGondi
Gothic
Grantha
Greek
Gujarati
Gurmukhi
Hangul
Han
Hanunoo
Hatran
Hebrew
Hiragana
AnatolianHieroglyphs
PahawhHmong
NyiakengPuachueHmong
OldHungarian
OldItalic
Javanese
KayahLi
Katakana
Kharoshthi
Khmer
Khojki
KhitanSmallScript
Kannada
Kaithi
TaiTham
Lao
Latin
Lepcha
Limbu
LinearA
LinearB
Lisu
Lycian
Lydian
Mahajani
Makasar
Mandaic
Manichaean
Marchen
Medefaidrin
MendeKikakui
MeroiticCursive
MeroiticHieroglyphs
Malayalam
Modi
Mongolian
Mro
MeeteiMayek
Multani
Myanmar
Nandinagari
OldNorthArabian
Nabataean
Newa
Nko
Nushu
Ogham
OlChiki
OldTurkic
Oriya
Osage
Osmanya
Palmyrene
PauCinHau
OldPermic
PhagsPa
InscriptionalPahlavi
PsalterPahlavi
Phoenician
Miao
InscriptionalParthian
Rejang
HanifiRohingya
Runic
Samaritan
OldSouthArabian
Saurashtra
SignWriting
Shavian
Sharada
Siddham
Khudawadi
Sinhala
Sogdian
OldSogdian
SoraSompeng
Soyombo
Sundanese
SylotiNagri
Syriac
Tagbanwa
Takri
TaiLe
NewTaiLue
Tamil
Tangut
TaiViet
Telugu
Tifinagh
Tagalog
Thaana
Thai
Tibetan
Tirhuta
Ugaritic
Vai
WarangCiti
Wancho
OldPersian
Cuneiform
Yezidi
Yi
ZanabazarSquare
Inherited
Common
Unknown
}pub struct Setting[T] {
tag : UInt
value : T
}
fn Setting::Setting(tag : UInt, value : T) -> Setting[T]pub(all) enum ShapeClass {
Reph
Pref
Kinzi
Base
Mark
Halant
MedialRa
VMPre
VPre
VBlw
Anusvara
Zwj
Zwnj
Control
Vs
Other
}pub struct SourceRange {
// private fields
}
fn SourceRange::SourceRange(start : UInt, end : UInt) -> SourceRangepub(all) enum Status {
Discard
Keep
Complete
}pub struct Stretch {
value : UInt16
}pub(all) enum StringId {
Copyright
Family
SubFamily
UniqueId
Full
Version
PostScript
Trademark
Manufacturer
Designer
Description
VendorUrl
DesignerUrl
License
LicenseUrl
TypographicFamily
TypographicSubFamily
CompatibleFull
SampleText
PostScriptCid
WwsFamily
WwsSubFamily
LightBackgroundPalette
DarkBackgroundPalette
VariationsPostScriptNamePrefix
Other(UInt16)
}pub(all) enum Usability {
Light
Dark
Both
}pub(all) enum UseClass {
B
CGJ
CMAbv
CMBlw
CS
FAbv
FBlw
FPst
FM
GB
H
HN
IND
MAbv
MBlw
MPre
MPst
N
O
R
Rsv
S
SMAbv
SMBlw
SUB
VAbv
VBlw
VPre
VPst
VMAbv
VMBlw
VMPre
VMPst
VS
WJ
ZWJ
ZWNJ
}type Variationtype Variationstype VariationsProxypub struct Weight {
value : UInt16
}pub(all) enum Whitespace {
None
Space
NoBreakSpace
Tab
Newline
Other
}pub(all) enum WordBreak {
CR
DQ
EX
Extend
FO
HL
KA
LE
LF
MB
ML
MN
NL
NU
RI
SQ
WSegSpace
XX
ZWJ
}pub(all) enum WordBreakStrength {
Normal
BreakAll
KeepAll
}type WritingSystemtype WritingSystemslet MAX_CLUSTER_SIZE : Intlet UNICODE_VERSION_MAJOR : Intfn desc_from_aat(feature : UInt16, selector : UInt16) -> (Int, UInt, String)?fn desc_from_at(tag : UInt) -> (Int, String)?Dependencies