Skip to content

Commit

Permalink
font-manager: use the option API by default
Browse files Browse the repository at this point in the history
  • Loading branch information
EduardoRFS committed Jun 24, 2020
1 parent 647daf6 commit f33cbba
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion examples/font-manager-cli/FontQuery.re
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ let spec = [

Arg.parse(spec, _ => (), "Simple CLI utility to test findFont");

FontManager.findFont(
FontManager.findFontExn(
~family=fontFamily^,
~weight=
isBold^ ? FontManager.FontWeight.Bold : FontManager.FontWeight.Normal,
Expand Down
2 changes: 1 addition & 1 deletion src/Font/Discovery.re
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ let find =
~italic=false,
family,
) =>
FontManager.findFont(~weight, ~width, ~mono, ~italic, ~family, ());
FontManager.findFontExn(~weight, ~width, ~mono, ~italic, ~family, ());

let toString = FontManager.FontDescriptor.show;
6 changes: 3 additions & 3 deletions src/reason-font-manager/FontManager.re
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module FontWidth = FontWidth;
external findFont': (string, int, int, bool, bool) => FontDescriptor.raw =
"fm_findFont";

let findFontOpt =
let findFont =
(
~weight=FontWeight.Normal,
~width=FontWidth.Undefined,
Expand All @@ -29,7 +29,7 @@ let findFontOpt =
};

exception Font_not_found;
let findFont =
let findFontExn =
(
~weight=FontWeight.Normal,
~width=FontWidth.Undefined,
Expand All @@ -38,7 +38,7 @@ let findFont =
~mono: bool,
(),
) => {
switch (findFontOpt(~weight, ~width, ~family, ~italic, ~mono, ())) {
switch (findFont(~weight, ~width, ~family, ~italic, ~mono, ())) {
| None => raise(Font_not_found)
| Some(fontDescriptor) => fontDescriptor
};
Expand Down
6 changes: 3 additions & 3 deletions src/reason-font-manager/FontManager.rei
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ let findFont:
~mono: bool,
unit
) =>
FontDescriptor.t;
let findFontOpt:
option(FontDescriptor.t);
let findFontExn:
(
~weight: FontWeight.t=?,
~width: FontWidth.t=?,
Expand All @@ -22,4 +22,4 @@ let findFontOpt:
~mono: bool,
unit
) =>
option(FontDescriptor.t);
FontDescriptor.t;

0 comments on commit f33cbba

Please sign in to comment.