/* Copyright (c) 2001, Stanford University
* All rights reserved
*
* See the file LICENSE.txt for information on redistributing this software.
*/
#include "chromium.h"
#include "cr_error.h"
#include "cr_mem.h"
#include "stub.h"
/** code borrowed from Mesa */
/** Fill a BITMAP with a character C from thew current font
in the graphics context GC. WIDTH is the width in bytes
and HEIGHT is the height in bits.
Note that the generated bitmaps must be used with
glPixelStorei (GL_UNPACK_SWAP_BYTES, GL_FALSE);
glPixelStorei (GL_UNPACK_LSB_FIRST, GL_FALSE);
glPixelStorei (GL_UNPACK_ROW_LENGTH, 0);
glPixelStorei (GL_UNPACK_SKIP_ROWS, 0);
glPixelStorei (GL_UNPACK_SKIP_PIXELS, 0);
glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
Possible optimizations:
* use only one reusable pixmap with the maximum dimensions.
* draw the entire font into a single pixmap (careful with
proportional fonts!).
*/
/**
* Generate OpenGL-compatible bitmap.
*/
static void
{
unsigned int x, y;
if (image) {
/* Fill the bitmap (X11 and OpenGL are upside down wrt each other). */
for (y = 0; y < height; y++)
for (x = 0; x < 8*width; x++)
}
}
/*
* determine if a given glyph is valid and return the
* corresponding XCharStruct.
*/
{
if (rows == 1) {
/* "linear" fonts */
}
else {
/* "matrix" fonts */
}
if (valid) {
if (rows == 1) {
/* "linear" fonts */
}
else {
/* "matrix" fonts */
}
}
else {
return &fs->min_bounds;
}
}
return NULL;
}
{
unsigned long valuemask;
int i;
if (!fs) {
crWarning("Couldn't get font structure information");
return;
}
/* Allocate a bitmap that can fit all characters. */
if (!bm) {
crWarning("Couldn't allocate bitmap in glXUseXFont()");
return;
}
/* Save the current packing mode for bitmaps. */
/* Enforce a standard packing mode which is compatible with
fill_bitmap() from above. This is actually the default mode,
except for the (non)alignment. */
for (i = 0; i < count; i++) {
int x, y;
unsigned int c = first + i;
int valid;
/* check on index validity and get the bounds */
if (!ch) {
valid = 0;
}
else {
valid = 1;
}
/* glBitmap()' parameters:
straight from the glXUseXFont(3) manpage. */
/* but that caused a conformance failure */
dy = 0;
/* X11's starting point. */
/* Round the width to a multiple of eight. We will use this also
for the pixmap for capturing the X11 font. This is slightly
inefficient, but it makes the OpenGL part real easy. */
}
else {
}
glEndList();
}
/* Restore saved packing modes. */
}