File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1111#undef HB_NO_VAR_COMPOSITES
1212#undef HB_NO_NAME
1313#undef HB_NO_LAYOUT_FEATURE_PARAMS
14+ #undef HB_NO_LAYOUT_RARELY_USED
1415#define HB_BUFFER_MESSAGE_MORE 1
Original file line number Diff line number Diff line change @@ -79,6 +79,7 @@ _hb_ot_layout_table_get_feature_tags
7979_hb_ot_layout_script_get_language_tags
8080_hb_ot_layout_language_get_feature_tags
8181_hb_ot_layout_feature_get_lookups
82+ _hb_ot_layout_lookup_get_optical_bound
8283_hb_ot_layout_get_glyph_class
8384_hb_ot_layout_feature_get_name_ids
8485_hb_ot_name_list_names
Original file line number Diff line number Diff line change 66 string_to_utf8_ptr ,
77} from "./helpers" ;
88import type { FontExtents , GlyphExtents , SvgPathCommand } from "./types" ;
9+ import type { Direction } from "./buffer" ;
910import type { Face } from "./face" ;
1011import type { FontFuncs } from "./font-funcs" ;
1112import type { Variation } from "./variation" ;
@@ -453,4 +454,25 @@ export class Font {
453454 setFuncs ( fontFuncs : FontFuncs ) : void {
454455 exports . hb_font_set_funcs ( this . ptr , fontFuncs . ptr ) ;
455456 }
457+
458+ /**
459+ * Fetches the optical bound of a glyph positioned at the margin of text.
460+ * The direction identifies which edge of the glyph to query.
461+ * @param lookupIndex Index of the feature lookup to query.
462+ * @param direction Edge of the glyph to query.
463+ * @param glyph A glyph id.
464+ * @returns Adjustment value. Negative values mean the glyph will stick out of the margin.
465+ */
466+ getLookupOpticalBound (
467+ lookupIndex : number ,
468+ direction : Direction ,
469+ glyph : number ,
470+ ) : number {
471+ return exports . hb_ot_layout_lookup_get_optical_bound (
472+ this . ptr ,
473+ lookupIndex ,
474+ direction ,
475+ glyph ,
476+ ) ;
477+ }
456478}
Original file line number Diff line number Diff line change @@ -520,6 +520,23 @@ describe("Font", function () {
520520 expect ( font . glyph ( 0x10ffff ) ) . to . equal ( font . nominalGlyph ( 0x10ffff ) ) ;
521521 } ) ;
522522
523+ it ( "getLookupOpticalBound returns some value" , function ( ) {
524+ let blob = new hb . Blob (
525+ fs . readFileSync ( path . join ( __dirname , "fonts/noto/NotoSans-Regular.ttf" ) ) ,
526+ ) ;
527+ let face = new hb . Face ( blob ) ;
528+ let font = new hb . Font ( face ) ;
529+ const kernIndex = face . getTableFeatureTags ( "GPOS" ) . indexOf ( "kern" ) ;
530+ const [ lookupIndex ] = face . getFeatureLookups ( "GPOS" , kernIndex ) ;
531+ const glyph = font . glyphFromName ( "A" ) ;
532+ const opticalBound = font . getLookupOpticalBound (
533+ lookupIndex ,
534+ hb . Direction . LTR ,
535+ glyph ,
536+ ) ;
537+ expect ( opticalBound ) . to . be . a ( "number" ) ;
538+ } ) ;
539+
523540 it ( "setVariations affects advances" , function ( ) {
524541 let blob = new hb . Blob (
525542 fs . readFileSync (
You can’t perform that action at this time.
0 commit comments