forked from revery-ui/revery
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
505fde9
commit 338d44e
Showing
3 changed files
with
109 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,55 @@ | ||
#include <stdio.h> | ||
#include <caml/alloc.h> | ||
#include <caml/bigarray.h> | ||
#include <caml/callback.h> | ||
#include <caml/memory.h> | ||
#include <caml/mlvalues.h> | ||
#include <caml/threads.h> | ||
#include "FontDescriptor.h" | ||
extern "C" { | ||
extern FontDescriptor *findFont(FontDescriptor *query); | ||
extern ResultSet *findFonts(FontDescriptor *query); | ||
CAMLprim value fm_findFont(value family, value weight, value width, value italic, value monospace) { | ||
CAMLparam5(family, weight, width, italic, monospace); | ||
CAMLlocal1(ret); | ||
const char* fontFamily = String_val(family); | ||
FontWeight weightToCheck = (FontWeight)Int_val(weight); | ||
FontWidth widthToCheck = (FontWidth)Int_val(width); | ||
int isItalic = Bool_val(italic); | ||
int isMono = Bool_val(monospace); | ||
caml_release_runtime_system(); | ||
FontDescriptor *query = new FontDescriptor(NULL, NULL, fontFamily, NULL, weightToCheck, widthToCheck, isItalic, isMono); | ||
FontDescriptor *font = findFont(query); | ||
delete query; | ||
|
||
caml_acquire_runtime_system(); | ||
ret = caml_alloc(7, 0); | ||
Store_field(ret, 0, caml_copy_string(font->path)); | ||
Store_field(ret, 1, caml_copy_string(font->postscriptName)); | ||
Store_field(ret, 2, caml_copy_string(font->family)); | ||
Store_field(ret, 3, Val_int(font->weight)); | ||
Store_field(ret, 4, Val_int(font->width)); | ||
Store_field(ret, 5, Val_bool(font->italic)); | ||
Store_field(ret, 6, Val_bool(font->monospace)); | ||
|
||
delete font; | ||
CAMLreturn(ret); | ||
} | ||
} | ||
#include <caml/alloc.h> | ||
#include <caml/bigarray.h> | ||
#include <caml/callback.h> | ||
#include <caml/fail.h> | ||
#include <caml/memory.h> | ||
#include <caml/mlvalues.h> | ||
#include <caml/threads.h> | ||
#include <stdio.h> | ||
|
||
#include "FontDescriptor.h" | ||
|
||
extern "C" { | ||
|
||
extern FontDescriptor *findFont(FontDescriptor *query); | ||
extern ResultSet *findFonts(FontDescriptor *query); | ||
|
||
CAMLprim value fm_findFont(value family, value weight, value width, value italic, value monospace) { | ||
CAMLparam5(family, weight, width, italic, monospace); | ||
CAMLlocal1(ret); | ||
|
||
const char *fontFamily = String_val(family); | ||
FontWeight weightToCheck = (FontWeight)Int_val(weight); | ||
FontWidth widthToCheck = (FontWidth)Int_val(width); | ||
int isItalic = Bool_val(italic); | ||
int isMono = Bool_val(monospace); | ||
|
||
caml_release_runtime_system(); | ||
|
||
FontDescriptor *query = new FontDescriptor(NULL, NULL, fontFamily, NULL, weightToCheck, widthToCheck, isItalic, isMono); | ||
FontDescriptor *font = findFont(query); | ||
|
||
delete query; | ||
|
||
if (font == NULL) { | ||
caml_raise_not_found(); | ||
return Val_unit; | ||
} | ||
|
||
caml_acquire_runtime_system(); | ||
|
||
ret = caml_alloc(7, 0); | ||
|
||
Store_field(ret, 0, caml_copy_string(font->path)); | ||
Store_field(ret, 1, caml_copy_string(font->postscriptName)); | ||
Store_field(ret, 2, caml_copy_string(font->family)); | ||
Store_field(ret, 3, Val_int(font->weight)); | ||
Store_field(ret, 4, Val_int(font->width)); | ||
Store_field(ret, 5, Val_bool(font->italic)); | ||
Store_field(ret, 6, Val_bool(font->monospace)); | ||
|
||
delete font; | ||
|
||
CAMLreturn(ret); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
module FontDescriptor = FontDescriptor; | ||
module FontWeight = FontWeight; | ||
module FontWidth = FontWidth; | ||
|
||
exception Font_not_found; | ||
let findFont: | ||
( | ||
~weight: FontWeight.t=?, | ||
~width: FontWidth.t=?, | ||
~family: string, | ||
~italic: bool, | ||
~mono: bool, | ||
unit | ||
) => | ||
FontDescriptor.t; | ||
let findFontOpt: | ||
( | ||
~weight: FontWeight.t=?, | ||
~width: FontWidth.t=?, | ||
~family: string, | ||
~italic: bool, | ||
~mono: bool, | ||
unit | ||
) => | ||
option(FontDescriptor.t); |