-
Notifications
You must be signed in to change notification settings - Fork 642
Variable font support #3703
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Variable font support #3703
Changes from all commits
379a101
602c496
385ed8f
39b5386
b24f0b7
ec65fe0
15b4761
cf45dc9
af42511
4b93266
a18b2f2
896f457
a0c773b
85dc06a
3edbb88
9ebcf55
b769642
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -320,3 +320,4 @@ fastlane/screenshots | |
|
|
||
| # Docs worktree (docs branch) | ||
| .docs | ||
| .playwright-mcp/ | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -85,6 +85,101 @@ public Blob ReferenceTable (Tag table) => | |
|
|
||
| public void MakeImmutable () => HarfBuzzApi.hb_face_make_immutable (Handle); | ||
|
|
||
| // Variable font support | ||
|
|
||
| public bool HasVariationData => HarfBuzzApi.hb_ot_var_has_data (Handle); | ||
|
|
||
| public int VariationAxisCount => | ||
| (int)HarfBuzzApi.hb_ot_var_get_axis_count (Handle); | ||
|
|
||
| public OpenTypeVarAxisInfo[] VariationAxisInfos | ||
| { | ||
| get { | ||
| var count = HarfBuzzApi.hb_ot_var_get_axis_count (Handle); | ||
| if (count == 0) | ||
| return Array.Empty<OpenTypeVarAxisInfo> (); | ||
|
|
||
| var axes = new OpenTypeVarAxisInfo[(int)count]; | ||
| fixed (OpenTypeVarAxisInfo* ptr = axes) { | ||
| HarfBuzzApi.hb_ot_var_get_axis_infos (Handle, 0, &count, ptr); | ||
| } | ||
| return axes; | ||
| } | ||
| } | ||
|
|
||
| public int GetVariationAxisInfos (Span<OpenTypeVarAxisInfo> axes) | ||
| { | ||
| uint count = (uint)axes.Length; | ||
| fixed (OpenTypeVarAxisInfo* ptr = axes) { | ||
| HarfBuzzApi.hb_ot_var_get_axis_infos (Handle, 0, &count, ptr); | ||
| } | ||
| return (int)count; | ||
| } | ||
|
|
||
| public bool TryFindVariationAxis (Tag tag, out OpenTypeVarAxisInfo axisInfo) | ||
| { | ||
| axisInfo = default; | ||
| fixed (OpenTypeVarAxisInfo* ptr = &axisInfo) { | ||
| return HarfBuzzApi.hb_ot_var_find_axis_info (Handle, tag, ptr); | ||
| } | ||
| } | ||
|
|
||
| public int NamedInstanceCount => | ||
| (int)HarfBuzzApi.hb_ot_var_get_named_instance_count (Handle); | ||
|
|
||
| public OpenTypeNameId GetNamedInstanceSubfamilyNameId (int instanceIndex) | ||
| { | ||
| if (instanceIndex < 0) | ||
| throw new ArgumentOutOfRangeException (nameof (instanceIndex)); | ||
| return HarfBuzzApi.hb_ot_var_named_instance_get_subfamily_name_id (Handle, (uint)instanceIndex); | ||
| } | ||
|
|
||
| public OpenTypeNameId GetNamedInstancePostScriptNameId (int instanceIndex) | ||
| { | ||
| if (instanceIndex < 0) | ||
| throw new ArgumentOutOfRangeException (nameof (instanceIndex)); | ||
| return HarfBuzzApi.hb_ot_var_named_instance_get_postscript_name_id (Handle, (uint)instanceIndex); | ||
| } | ||
|
|
||
| public int GetNamedInstanceDesignCoordsCount (int instanceIndex) | ||
| { | ||
| if (instanceIndex < 0) | ||
| throw new ArgumentOutOfRangeException (nameof (instanceIndex)); | ||
|
|
||
| // Return value is the total number of design coordinates | ||
| return (int)HarfBuzzApi.hb_ot_var_named_instance_get_design_coords (Handle, (uint)instanceIndex, null, null); | ||
|
mattleibow marked this conversation as resolved.
|
||
| } | ||
|
Comment on lines
+144
to
+151
|
||
|
|
||
| public float[] GetNamedInstanceDesignCoords (int instanceIndex) | ||
| { | ||
| if (instanceIndex < 0) | ||
| throw new ArgumentOutOfRangeException (nameof (instanceIndex)); | ||
|
|
||
| // Return value is the total number of design coordinates | ||
| var totalCoords = (int)HarfBuzzApi.hb_ot_var_named_instance_get_design_coords (Handle, (uint)instanceIndex, null, null); | ||
| if (totalCoords == 0) | ||
| return Array.Empty<float> (); | ||
|
mattleibow marked this conversation as resolved.
|
||
|
|
||
| uint coordsLength = (uint)totalCoords; | ||
| var coords = new float[totalCoords]; | ||
| fixed (float* ptr = coords) { | ||
| HarfBuzzApi.hb_ot_var_named_instance_get_design_coords (Handle, (uint)instanceIndex, &coordsLength, ptr); | ||
|
Comment on lines
+153
to
+166
|
||
| } | ||
| return coords; | ||
| } | ||
|
|
||
| public int GetNamedInstanceDesignCoords (int instanceIndex, Span<float> coords) | ||
| { | ||
| if (instanceIndex < 0) | ||
| throw new ArgumentOutOfRangeException (nameof (instanceIndex)); | ||
|
|
||
| uint coordsLength = (uint)coords.Length; | ||
| fixed (float* ptr = coords) { | ||
| HarfBuzzApi.hb_ot_var_named_instance_get_design_coords (Handle, (uint)instanceIndex, &coordsLength, ptr); | ||
| } | ||
| return (int)coordsLength; | ||
| } | ||
|
|
||
| protected override void Dispose (bool disposing) => | ||
| base.Dispose (disposing); | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.