Пример #1
0
/*!
	\brief Sets the ServerFont instance to whatever font is specified
	\param fontID the combination of family and style ID numbers
	\return B_OK if successful, B_ERROR if not
*/
status_t
ServerFont::SetFamilyAndStyle(uint32 fontID)
{
	uint16 style = fontID & 0xFFFF;
	uint16 family = (fontID & 0xFFFF0000) >> 16;

	return SetFamilyAndStyle(family, style);
}
Пример #2
0
status_t
FFont::Unflatten(type_code c, const void *buf, ssize_t size)
{
    if( c != FONT_TYPE ) return B_BAD_TYPE;

    // Make sure buffer contains all data.  If we later want
    // to add new attributes, we can make a more sophisticated
    // check to allow partial structures.
    if( size < sizeof(flat_font_data) ) return B_BAD_VALUE;

    // Easy reference to the buffer.
    flat_font_data* fdat = (flat_font_data*)buf;

    // Initialize from default font, just in case.
    *this = FFont();

    // Set up family and style for font.
    SetFamilyAndStyle(fdat->family,fdat->style);

    // This is used as a temporary when byte-swapping floats.
    // Note that this assumes a float is 4 bytes.
    union {
        uint32 aslong;
        float asfloat;
    } swap;

    // Byte-swap size, shear, and rotation out of the flattened
    // structure.  This is written for clarity more than speed,
    // since the additional overhead will be entirely subsumed
    // by everything else going on.
    swap.asfloat = fdat->size;
    swap.aslong = ntohl(swap.aslong);
    SetSize(swap.asfloat);
    swap.asfloat = fdat->shear;
    swap.aslong = ntohl(swap.aslong);
    SetShear(swap.asfloat);
    swap.asfloat = fdat->rotation;
    swap.aslong = ntohl(swap.aslong);
    SetRotation(swap.asfloat);

    // Byte-swap the remaining data from the flattened structure.
    SetFlags(ntohl(fdat->flags));
    SetFace(ntohs(fdat->face));
    SetSpacing(fdat->spacing);
    SetEncoding(fdat->encoding);
    SetMask(ntohl(fdat->mask));

    return B_NO_ERROR;
}