Struct pdf_canvas::Encoding [] [src]

pub struct Encoding { /* fields omitted */ }

Represent a text encoding used in PDF. An encoding maintains the connection between unicode code points, bytes in PDF strings, and glyph names.

Currently, only WIN_ANSI_ENCODING and SYMBOL_ENCODING are supported, and they are provided as built-in.

Example

use pdf_canvas::{BuiltinFont, FontSource};
assert_eq!("WinAnsiEncoding",
           BuiltinFont::Helvetica.get_encoding().get_name());
assert_eq!("SymbolEncoding",
           BuiltinFont::Symbol.get_encoding().get_name());

Methods

impl Encoding
[src]

The name of the encoding, as used in the font object.

Get the encoded code point from a type1 character name. Character names are case sensitive and contains only ascii letters. If the name is not available in the encoding, or is not a proper character name, None is returned.

Example

use pdf_canvas::{BuiltinFont, FontSource};
let enc = BuiltinFont::Helvetica.get_encoding();
assert_eq!(Some(32),  enc.get_code("space"));
assert_eq!(Some(65),  enc.get_code("A"));
assert_eq!(Some(229), enc.get_code("aring"));
assert_eq!(None,      enc.get_code("Lslash"));
assert_eq!(None,      enc.get_code(""));
assert_eq!(None,      enc.get_code("☺"));

Convert a rust string to a vector of bytes in the encoding.

Example

use pdf_canvas::{BuiltinFont, FontSource};
let enc = BuiltinFont::Helvetica.get_encoding();
let symb_enc = BuiltinFont::Symbol.get_encoding();
assert_eq!(vec!(65, 66, 67), enc.encode_string("ABC"));
assert_eq!(vec!(82, 228, 107, 115, 109, 246, 114, 103, 229, 115),
           enc.encode_string("Räksmörgås"));
assert_eq!(vec!(67, 111, 102, 102, 101, 101, 32, 128, 49, 46, 50, 48),
           enc.encode_string("Coffee €1.20"));
assert_eq!(vec!(97, 32, 206, 32, 194),
           symb_enc.encode_string("α ∈ ℜ"));

Trait Implementations

impl Debug for Encoding
[src]

Formats the value using the given formatter.

impl PartialEq for Encoding
[src]

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

impl Eq for Encoding
[src]

impl Hash for Encoding
[src]

Feeds this value into the state given, updating the hasher as necessary.

Feeds a slice of this type into the state provided.

impl Clone for Encoding
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more