pub fn create_font(
        &self,
        name: &str,
        filename: &str,
    ) -> std::result::Result<Font, Box<dyn std::error::Error>> {
        let name = std::ffi::CString::new(name).unwrap();
        let filename = std::ffi::CString::new(filename).unwrap();
        let handle = unsafe { sys::nvgCreateFont(self.ctx, name.as_ptr(), filename.as_ptr()) };
        match handle {
            -1 => Err(Box::new(std::io::Error::new(
                std::io::ErrorKind::Other,
                "unable to load font",
            ))),
            _ => Ok(Font { handle }),
        }
    }
/// NanoVG allows you to load .ttf files and use the font to render text.
///
/// The appearance of the text can be defined by setting the current text style
/// and by specifying the fill color. Common text and font settings such as
/// font size, letter spacing and text align are supported. Font blur allows you
/// to create simple text effects such as drop shadows.
///
/// At render time the font face can be set based on the font handles or name.
///
/// Font measure functions return values in local space, the calculations are
/// carried in the same resolution as the final rendering. This is done because
/// the text glyph positions are snapped to the nearest pixels sharp rendering.
///
/// The local space means that values are not rotated or scale as per the current
/// transformation. For example if you set font size to 12, which would mean that
/// line height is 16, then regardless of the current scaling and rotation, the
/// returned line height is always 16. Some measures may vary because of the scaling
/// since aforementioned pixel snapping.
///
/// While this may sound a little odd, the setup allows you to always render the
/// same way regardless of scaling.
///
/// Note: currently only solid color fill is supported for text.
NanoVG allows you to load .ttf files and use the font to render text.
The appearance of the text can be defined by setting the current text style
and by specifying the fill color. Common text and font settings such as
font size, letter spacing and text align are supported. Font blur allows you
to create simple text effects such as drop shadows.

At render time the font face can be set based on the font handles or name.

Font measure functions return values in local space, the calculations are
carried in the same resolution as the final rendering. This is done because
the text glyph positions are snapped to the nearest pixels sharp rendering.

The local space means that values are not rotated or scale as per the current
transformation. For example if you set font size to 12, which would mean that
line height is 16, then regardless of the current scaling and rotation, the
returned line height is always 16. Some measures may vary because of the scaling
since aforementioned pixel snapping.

While this may sound a little odd, the setup allows you to always render the
same way regardless of scaling.

currently only solid color fill is supported for text.
NanoVG allows you to load . ttf files and use the font to render text . The appearance of the text can be defined by setting the current text style and by specifying the fill color . Common text and font settings such as font size letter spacing and text align are supported . Font blur allows you to create simple text effects such as drop shadows . At render time the font face can be set based on the font handles or name . Font measure functions return values in local space the calculations are carried in the same resolution as the final rendering . This is done because the text glyph positions are snapped to the nearest pixels sharp rendering . The local space means that values are not rotated or scale as per the current transformation . For example if you set font size to 12 which would mean that line height is 16 then regardless of the current scaling and rotation the returned line height is always 16 . Some measures may vary because of the scaling since aforementioned pixel snapping . While this may sound a little odd the setup allows you to always render the same way regardless of scaling . currently only solid color fill is supported for text .
pub fn create_font(
        &self,
        name: &str,
        filename: &str,
    ) -> std::result::Result<Font, Box<dyn std::error::Error>> {
        let name = std::ffi::CString::new(name).unwrap();
        let filename = std::ffi::CString::new(filename).unwrap();
        let handle = unsafe { sys::nvgCreateFont(self.ctx, name.as_ptr(), filename.as_ptr()) };
        match handle {
            -1 => Err(Box::new(std::io::Error::new(
                std::io::ErrorKind::Other,
                "unable to load font",
            ))),
            _ => Ok(Font { handle }),
        }
    }
pub fn create_font ( & self , name : & str , filename : & str , ) -> std :: result :: Result < Font , Box < dyn std :: error :: Error > > { let name = std :: ffi :: CString :: new ( name ) . unwrap ( ) ; let filename = std :: ffi :: CString :: new ( filename ) . unwrap ( ) ; let handle = unsafe { sys :: nvgCreateFont ( self . ctx , name . as_ptr ( ) , filename . as_ptr ( ) ) } ; match handle { - 1 => Err ( Box :: new ( std :: io :: Error :: new ( std :: io :: ErrorKind :: Other , " " , ) ) ) , _ => Ok ( Font { handle } ) , } }
NanoVG allows you to load .ttf files and use the font to render text.
NanoVG allows you to load . ttf files and use the font to render text .
&self
name
&str
filename
&str