PyOpenGL利用文泉驿正黑字体显示中文字体
摘要:在NeHe的OpenGL教程第43课源代码基础上,调用文泉驿正黑字体实现中文字体的显示
在OpenGL中显示汉字一直是个麻烦的事情,很多中文书籍的文抄公乐此不疲地介绍各种方法及其在windows下的代码实现。此处不在赘述,有兴趣的可以参考下面的文章:
OpenGL点阵字体绘制终极解决方案!哈!
下面的代码是在NeHe教程第43课的基础上,添加了中文字体显示功能,原则上只要字体库支持,任何unicode字符串都是可以显示的
btw,unbutu下字体库文件位置:/usr/share/fonts/
16/09/14 晚补注:
在Windos下请安装PIL的替代产品pillow并相应修改
- import ImageFont
为
- from PIL import ImageFont
python代码:
- #! /usr/bin/env python
- #coding=utf-8
- # Modified from following code by T.Q. 2014
- # A quick and simple opengl font library that uses GNU freetype2, written
- # and distributed as part of a tutorial for nehe.gamedev.net.
- # Sven Olsen, 2003
- # Translated to PyOpenGL by Brian Leair, 2004
- #
- #
- import ImageFont
- import numpy as np
- from OpenGL import GL,GLU
- def is_cjk(uchar):
- '''
- Checks for an unicode whether a CJK character
- '''
- # cjk = (u'\u4e00',u'\u9fa5')
- cjk = (u'\u2e80',u'\ufe4f')
- if cjk[0]<=uchar<=cjk[1]:
- return True
- else:
- return False
- def is_ascii(uchar):
- '''
- Checks for an unicode whether a ASCII character
- '''
- ascii = (u'\u0000',u'\u00ff')
- if ascii[0]<=uchar<=ascii[1]:
- return True
- else:
- return False
- def is_other(uchar):
- '''
- Checks for an unicode whether an ASCII or CJK character
- '''
- if not (is_cjk(uchar) or is_ascii(uchar)):
- return True
- else:
- return False
- def nextpow2(x):
- '''
- If num isn't a power of 2, will return the next higher power of two
- '''
- if x>=1.0:
- return np.int(2**np.ceil(np.log2(x)))
- else:
- print "cannot convert negetive float to integer:",x
- def getCharData(ft,uchar):
- '''
- '''
- # Use our helper function to get the widths of
- # the bitmap data that we will need in order to create
- # our texture.
- if isinstance(uchar,int):
- glyph = ft.getmask(chr(uchar))
- elif isinstance(uchar,unicode):
- if is_other(uchar):
- return [None]*5
- else:
- glyph = ft.getmask(uchar)
- elif isinstance(uchar,str):
- uchar = unicode(uchar)
- if is_other(uchar):
- return [None]*5
- else:
- glyph = ft.getmask(uchar)
- else:
- return [None]*5
- glyph_width,glyph_height = glyph.size
- # We are using PIL's wrapping for FreeType. As a result, we don't have
- # direct access to glyph.advance or other attributes, so we add a 1 pixel pad.
- width = nextpow2(glyph_width + 1)
- height = nextpow2(glyph_height + 1)
- # python GL will accept lists of integers or strings, but not Numeric arrays
- # so, we buildup a string for our glyph's texture from the Numeric bitmap
- # Here we fill in the data for the expanded bitmap.
- # Notice that we are using two channel bitmap (one for
- # luminocity and one for alpha), but we assign
- # both luminocity and alpha to the value that we
- # find in the FreeType bitmap.
- # We use the ?: operator so that value which we use
- # will be 0 if we are in the padding zone, and whatever
- # is the the Freetype bitmap otherwise.
- expanded_data = ""
- for j in xrange (height):
- for i in xrange (width):
- if (i >= glyph_width) or (j >= glyph_height):
- value = chr(0)
- expanded_data += value
- expanded_data += value
- else:
- value = chr(glyph.getpixel((i, j)))
- expanded_data += value
- expanded_data += value
- return glyph_width,glyph_height,width,height,expanded_data
- def make_dlist(ft,ch,list_base,tex_base_list,color=[0,1,0]):
- '''
- Given an integer char code, build a GL texture into texture_array,
- build a GL display list for display list number display_list_base + ch.
- Populate the glTexture for the integer ch and construct a display
- list that renders the texture for ch.
- Note, that display_list_base and texture_base are supposed
- to be preallocated for 256 consecutive display lists and and
- array of textures.
- '''
- # Load char data
- glyph_width,glyph_height,width,height,expanded_data = getCharData(ft,ch)
- if not glyph_width:
- return
- # -------------- Build the gl texture ------------
- # Now we just setup some texture paramaters.
- ID = GL.glGenTextures(1)
- tex_base_list[ch] = ID
- GL.glBindTexture(GL.GL_TEXTURE_2D, ID)
- GL.glTexParameterf(GL.GL_TEXTURE_2D,GL.GL_TEXTURE_MAG_FILTER,GL.GL_LINEAR)
- GL.glTexParameterf(GL.GL_TEXTURE_2D,GL.GL_TEXTURE_MIN_FILTER,GL.GL_LINEAR)
- border = 0
- # Here we actually create the texture itself, notice
- # that we are using GL_LUMINANCE_ALPHA to indicate that
- # we are using 2 channel data.
- GL.glTexImage2D(GL.GL_TEXTURE_2D,0,GL.GL_RGBA,width,height,border,
- GL.GL_LUMINANCE_ALPHA,GL.GL_UNSIGNED_BYTE,expanded_data)
- # With the texture created, we don't need to expanded data anymore
- expanded_data = None
- # --- Build the gl display list that draws the texture for this character ---
- # So now we can create the display list
- GL.glNewList(list_base+ch,GL.GL_COMPILE)
- if ch == ord(" "):
- glyph_advance = glyph_width
- GL.glTranslatef(glyph_advance, 0, 0)
- GL.glEndList()
- else:
- GL.glBindTexture(GL.GL_TEXTURE_2D, ID)
- GL.glPushMatrix()
- # // first we need to move over a little so that
- # // the character has the right amount of space
- # // between it and the one before it.
- # glyph_left = glyph.bbox [0]
- # glTranslatef(glyph_left, 0, 0)
- # // Now we move down a little in the case that the
- # // bitmap extends past the bottom of the line
- # // this is only true for characters like 'g' or 'y'.
- # glyph_descent = glyph.decent
- # glTranslatef(0, glyph_descent, 0)
- # //Now we need to account for the fact that many of
- # //our textures are filled with empty padding space.
- # //We figure what portion of the texture is used by
- # //the actual character and store that information in
- # //the x and y variables, then when we draw the
- # //quad, we will only reference the parts of the texture
- # //that we contain the character itself.
- x = np.float(glyph_width)/np.float(width)
- y = np.float(glyph_height)/np.float(height)
- # //Here we draw the texturemaped quads.
- # //The bitmap that we got from FreeType was not
- # //oriented quite like we would like it to be,
- # //so we need to link the texture to the quad
- # //so that the result will be properly aligned.
- GL.glBegin(GL.GL_QUADS)
- GL.glColor3fv(color)
- GL.glTexCoord2f(0,0), GL.glVertex2f(0,glyph_height)
- GL.glTexCoord2f(0,y), GL.glVertex2f(0,0)
- GL.glTexCoord2f(x,y), GL.glVertex2f(glyph_width,0)
- GL.glTexCoord2f(x,0), GL.glVertex2f(glyph_width, glyph_height)
- GL.glEnd()
- GL.glPopMatrix()
- # Note, PIL's FreeType interface hides the advance from us.
- # Normal PIL clients are rendering an entire string through FreeType, not
- # a single character at a time like we are doing here.
- # Because the advance value is hidden from we will advance
- # the "pen" based upon the rendered glyph's width. This is imperfect.
- GL.glTranslatef(glyph_width + 0.75, 0, 0)
- # //increment the raster position as if we were a bitmap font.
- # //(only needed if you want to calculate text length)
- # //glBitmap(0,0,0,0,face->glyph->advance.x >> 6,0,NULL)
- # //Finnish the display list
- GL.glEndList()
- return
- def dispCJK(ft,uchar,tex_base_list,color=[1,1,0]):
- '''
- '''
- # Load char data
- glyph_width,glyph_height,width,height,expanded_data = getCharData(ft,uchar)
- if glyph_width == None:
- return
- # -------------- Build the gl texture ------------
- # Now we just setup some texture paramaters.
- ID = GL.glGenTextures(1)
- tex_base_list.append(ID)
- GL.glBindTexture(GL.GL_TEXTURE_2D, ID)
- GL.glTexParameterf(GL.GL_TEXTURE_2D,GL.GL_TEXTURE_MAG_FILTER,GL.GL_LINEAR)
- GL.glTexParameterf(GL.GL_TEXTURE_2D,GL.GL_TEXTURE_MIN_FILTER,GL.GL_LINEAR)
- border = 0
- # Here we actually create the texture itself, notice
- # that we are using GL_LUMINANCE_ALPHA to indicate that
- # we are using 2 channel data.
- GL.glTexImage2D(GL.GL_TEXTURE_2D,0,GL.GL_RGBA,width,height,border,
- GL.GL_LUMINANCE_ALPHA,GL.GL_UNSIGNED_BYTE,expanded_data)
- # With the texture created, we don't need to expanded data anymore
- expanded_data = None
- GL.glBindTexture(GL.GL_TEXTURE_2D, ID)
- GL.glPushMatrix()
- x = np.float(glyph_width)/np.float(width)
- y = np.float(glyph_height)/np.float(height)
- GL.glBegin(GL.GL_QUADS)
- GL.glColor3fv(color)
- GL.glTexCoord2f(0,0), GL.glVertex2f(0,glyph_height)
- GL.glTexCoord2f(0,y), GL.glVertex2f(0,0)
- GL.glTexCoord2f(x,y), GL.glVertex2f(glyph_width,0)
- GL.glTexCoord2f(x,0), GL.glVertex2f(glyph_width, glyph_height)
- GL.glEnd()
- GL.glPopMatrix()
- GL.glTranslatef(glyph_width + 0.75, 0, 0)
- return
- def pushScreenCoordinateMatrix():
- # A fairly straight forward function that pushes
- # a projection matrix that will make object world
- # coordinates identical to window coordinates.
- GL.glPushAttrib(GL.GL_TRANSFORM_BIT)
- viewport = GL.glGetIntegerv(GL.GL_VIEWPORT)
- GL.glMatrixMode(GL.GL_PROJECTION)
- GL.glPushMatrix()
- GL.glLoadIdentity()
- GLU.gluOrtho2D(viewport[0],viewport[2],viewport[1],viewport[3])
- GL.glPopAttrib()
- return
- def pop_projection_matrix():
- # Pops the projection matrix without changing the current
- # MatrixMode.
- GL.glPushAttrib(GL.GL_TRANSFORM_BIT)
- GL.glMatrixMode(GL.GL_PROJECTION)
- GL.glPopMatrix()
- GL.glPopAttrib()
- return
- class font_data(object):
- '''
- '''
- def __init__(self, facename, pixel_height):
- # We haven't yet allocated textures or display lists
- self.m_allocated = False
- self.m_font_height = pixel_height
- self.m_facename = facename
- # Try to obtain the FreeType font
- try:
- self.ft = ImageFont.truetype (facename, pixel_height)
- except:
- raise ValueError, "Unable to locate true type font '%s'" % (facename)
- # Here we ask opengl to allocate resources for
- # all the textures and displays lists which we
- # are about to create.
- # Note: only ASCII character
- n = 256
- self.m_list_base = GL.glGenLists(n)
- # Consturct a list of 256 elements. This
- # list will be assigned the texture IDs we create for each glyph
- self.textures = [None] * n
- self.cjk_textures = []
- # This is where we actually create each of the fonts display lists.
- for i in xrange(n):
- make_dlist(self.ft, i, self.m_list_base, self.textures)
- self.m_allocated = True
- def glPrint(self,x,y,string,color=[1,0,0]):
- '''
- '''
- # We want a coordinate system where things coresponding to window pixels.
- pushScreenCoordinateMatrix()
- # //We make the height about 1.5* that of
- h = np.float(self.m_font_height)/0.63
- if not string:
- pop_projection_matrix()
- return
- else:
- if not isinstance(string,unicode):
- try:
- string = unicode(string)
- except:
- raise ValueError,"Can not convert to unicode",string
- # //Here is some code to split the text that we have been
- # //given into a set of lines.
- # //This could be made much neater by using
- # //a regular expression library such as the one avliable from
- # //boost.org (I've only done it out by hand to avoid complicating
- # //this tutorial with unnecessary library dependencies).
- # //Note: python string object has convenience method for this :)
- lines = string.split("\n")
- GL.glPushAttrib(GL.GL_LIST_BIT|GL.GL_CURRENT_BIT |GL.GL_ENABLE_BIT|GL.GL_TRANSFORM_BIT)
- GL.glMatrixMode(GL.GL_MODELVIEW)
- # GL.glDisable(GL.GL_LIGHTING)
- # GL.glEnable(GL.GL_TEXTURE_2D)
- # GL.glDisable(GL.GL_DEPTH_TEST)
- # GL.glEnable(GL.GL_BLEND)
- # GL.glBlendFunc(GL.GL_SRC_ALPHA,GL.GL_ONE_MINUS_SRC_ALPHA)
- GL.glListBase(self.m_list_base)
- modelview_matrix = GL.glGetFloatv(GL.GL_MODELVIEW_MATRIX)
- # //This is where the text display actually happens.
- # //For each line of text we reset the modelview matrix
- # //so that the line's text will start in the correct position.
- # //Notice that we need to reset the matrix, rather than just translating
- # //down by h. This is because when each character is
- # //draw it modifies the current matrix so that the next character
- # //will be drawn immediatly after it.
- for i in xrange(len(lines)):
- line = lines[i]
- GL.glPushMatrix()
- GL.glLoadIdentity ()
- GL.glTranslatef(x,y-h*i,0);
- GL.glMultMatrixf(modelview_matrix);
- # // The commented out raster position stuff can be useful if you need to
- # // know the length of the text that you are creating.
- # // If you decide to use it make sure to also uncomment the glBitmap command
- # // in make_dlist().
- # // glRasterPos2f(0,0);
- # glCallLists (line)
- for tt in line:
- if is_cjk(tt):
- dispCJK(self.ft,tt,self.cjk_textures)
- else:
- # print 'ascii',tt
- GL.glCallList(ord(tt)+1)
- # // rpos = glGetFloatv (GL_CURRENT_RASTER_POSITION)
- # // float len=x-rpos[0];
- GL.glPopMatrix()
- GL.glPopAttrib()
- pop_projection_matrix()
- def release(self):
- """ Release the gl resources for this Face.
- (This provides the functionality of KillFont () and font_data::clean ()
- """
- if self.m_allocated:
- # Free up the glTextures and the display lists for our face
- GL.glDeleteLists( self.m_list_base, 256);
- for ID in self.textures:
- GL.glDeleteTextures(ID)
- if self.cjk_textures:
- for ID in self.cjk_textures:
- GL.glDeleteTextures(ID)
- # Extra defensive. Clients that continue to try and use this object
- # will now trigger exceptions.
- self.list_base = None
- self.m_allocated = False
- def __del__ (self):
- """ Python destructor for when no more refs to this Face object """
- self.release()
- # Unit Test harness if this python module is run directly.
- if __name__=="__main__":
- print "testing availability of freetype font arial\n"
- ft = ImageFont.truetype ("Test.ttf", 15)
- if ft:
- print "Found the TrueType font 'Test.ttf'"
- else:
- print "faild to find the TrueTYpe font 'arial'\n"
freeTypeFont.py
- #! /usr/bin/env python
- #coding=utf-8
- # NeHe Tutorial Lesson: 43 - FreeType fonts in OpenGL
- #
- # Ported to PyOpenGL 2.0 by Brian Leair 18 Jan 2004
- #
- # This code was created by Jeff Molofee 2000
- #
- # The port was based on the PyOpenGL tutorials and from
- # PyOpenGLContext (tests/glprint.py)
- #
- # If you've found this code useful, feel free to let me know
- # at (Brian Leair telcom_sage@yahoo.com).
- #
- # See original source and C based tutorial at http://nehe.gamedev.net
- #
- # Note:
- # -----
- # This code is not an ideal example of Pythonic coding or use of OO
- # techniques. It is a simple and direct exposition of how to use the
- # Open GL API in Python via the PyOpenGL package. It also uses GLUT,
- # a high quality platform independent library. Due to using these APIs,
- # this code is more like a C program using procedural programming.
- #
- # To run this example you will need:
- # Python - www.python.org (v 2.3 as of 1/2004)
- # PyOpenGL - pyopengl.sourceforge.net (v 2.0.1.07 as of 1/2004)
- # Numeric Python - (v.22 of "numpy" as of 1/2004) numpy.sourceforge.net
- # Python Image Library - http://www.pythonware.com/products/pil/ (v1.1.4 or later)
- #
- # Make sure to get versions of Numeric, PyOpenGL, and PIL to match your
- # version of python.
- #
- #
- from OpenGL.GL import *
- from OpenGL.GLUT import *
- from OpenGL.GLU import *
- # Imports specific to Lesson 43
- #import glFreeType
- import freeTypeFont as glFreeType
- from math import cos
- import sys
- # Python 2.2 defines these directly
- try:
- True
- except NameError:
- True = 1==1
- False = 1==0
- # Some api in the chain is translating the keystrokes to this octal string
- # so instead of saying: ESCAPE = 27, we use the following.
- ESCAPE = '\033'
- # Number of the glut window.
- window = 0
- our_font = None
- # A general OpenGL initialization function. Sets all of the initial parameters.
- def InitGL(Width, Height): # We call this right after our OpenGL window is created.
- global our_font
- glShadeModel(GL_SMOOTH) # Enables Smooth Color Shading
- glClearColor(0.0, 0.0, 0.0, 0.5) # This Will Clear The Background Color To Black
- glClearDepth(1.0) # Enables Clearing Of The Depth Buffer
- glEnable(GL_DEPTH_TEST) # Enables Depth Testing
- glEnable(GL_TEXTURE_2D) # Enables texture mapping
- glDepthFunc(GL_LEQUAL) # The Type Of Depth Test To Do
- glHint (GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST) # Really Nice Perspective Calculations
- # Currently omitting the wgl based font. See lesson13.py for example use of wgl font.
- # FYI, the ttf font file "Test.ttf" in lesson43 is the typeface "Arial Black Italic".
- # our_font = glFreeType.font_data ("ARBLI___.ttf", 16)
- # our_font = glFreeType.font_data ("Test.ttf", 16)
- our_font = glFreeType.font_data("wqy-zenhei.ttc",20)
- return True
- # The function called when our window is resized (which shouldn't happen if you enable fullscreen, below)
- def ReSizeGLScene(Width, Height):
- if Height == 0: # Prevent A Divide By Zero If The Window Is Too Small
- Height = 1
- glViewport(0, 0, Width, Height) # Reset The Current Viewport And Perspective Transformation
- glMatrixMode(GL_PROJECTION)
- glLoadIdentity()
- # // field of view, aspect ratio, near and far
- # This will squash and stretch our objects as the window is resized.
- gluPerspective(45.0, float(Width)/float(Height), 0.1, 100.0)
- glMatrixMode(GL_MODELVIEW)
- glLoadIdentity()
- cnt1 = 0
- # The main drawing function.
- def DrawGLScene():
- global cnt1
- global our_font
- # Clear The Screen And The Depth Buffer
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
- glLoadIdentity() # Reset The View
- # Step back (away from objects)
- glTranslatef (0.0, 0.0, -1.0)
- # Currently - NYI - No WGL text
- # Blue Text
- # glColor3ub(0, 0, 0xff)
- #
- # // Position The WGL Text On The Screen
- # glRasterPos2f(-0.40f, 0.35f);
- # glPrint("Active WGL Bitmap Text With NeHe - %7.2f", cnt1);
- # Red Text
- glColor3ub (0xff, 0, 0)
- glPushMatrix ()
- glLoadIdentity ()
- # Spin the text, rotation around z axe == will appears as a 2d rotation of the text on our screen
- glRotatef (cnt1, 0, 0, 1)
- glScalef (1, 0.8 + 0.3* cos (cnt1/5), 1)
- glTranslatef (-180, 0, 0)
- our_font.glPrint(320, 240, u"Active123中文 \nFreeType Text 汉字- %7.2f\n{【丯丱丳丵饕餮】}、\n今日はとてもいい天気です。空は靑く" % (cnt1))
- glPopMatrix ()
- # //Uncomment this to test out print's ability to handle newlines.
- # our_font.glPrint (320, 240, "Here\nthere\nbe\n\nnewlines %f\n." % (cnt1))
- cnt1 += 0.091
- # cnt2 += 0.005
- glutSwapBuffers()
- return
- # The function called whenever a key is pressed. Note the use of Python tuples to pass in: (key, x, y)
- def keyPressed(*args):
- global window
- global our_font
- # If escape is pressed, kill everything.
- if args[0] == ESCAPE:
- our_font.release ()
- sys.exit()
- def main():
- global window
- # pass arguments to init
- glutInit(sys.argv)
- # Select type of Display mode:
- # Double buffer
- # RGBA color
- # Alpha components supported
- # Depth buffer
- glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_ALPHA | GLUT_DEPTH)
- # get a 640 x 480 window
- glutInitWindowSize(640, 480)
- # the window starts at the upper left corner of the screen
- glutInitWindowPosition(0, 0)
- # Okay, like the C version we retain the window id to use when closing, but for those of you new
- # to Python (like myself), remember this assignment would make the variable local and not global
- # if it weren't for the global declaration at the start of main.
- window = glutCreateWindow("NeHe & Sven Olsen's TrueType Font Tutorial")
- # Register the drawing function with glut, BUT in Python land, at least using PyOpenGL, we need to
- # set the function pointer and invoke a function to actually register the callback, otherwise it
- # would be very much like the C version of the code.
- glutDisplayFunc(DrawGLScene)
- # Uncomment this line to get full screen.
- #glutFullScreen()
- # When we are doing nothing, redraw the scene.
- glutIdleFunc(DrawGLScene)
- # Register the function called when our window is resized.
- glutReshapeFunc(ReSizeGLScene)
- # Register the function called when the keyboard is pressed.
- glutKeyboardFunc(keyPressed)
- # Initialize our window.
- InitGL(640, 480)
- # Start Event Processing Engine
- glutMainLoop()
- # Print message to console, and kick off the main to get it rolling.
- print "Hit ESC key to quit."
- main()
lesson43.py
Ubuntu 14.04
Win7
PyOpenGL利用文泉驿正黑字体显示中文字体的更多相关文章
- Ubuntu安装文泉驿-微米黑字体
sudo apt-get install ttf-wqy-microhei #文泉驿-微米黑
- fedora 下安装 文泉驿正黑体
1. 可以到文泉驿正黑体的 主页 http://wenq.org/wqy2/index.cgi?%E9%A6%96%E9%A1%B5 最好能去官网表示一下支持 2. 也可以直接使用命令 : sudo ...
- LinuxMint(Ubuntu)安装文泉驿家族黑体字
文泉驿黑体字家族在Ubuntu上很有用,可以解决系统字体发虚的问题. 通过下面的三条命令安装: sudo apt-get install ttf-wqy-microhei #文泉驿-微米黑 sudo ...
- Ubuntu 14.04 64位字体美化(使用黑文泉驿)
Ubuntu 14.04安装和升级后,,斜体字体变得很难看,昨天,我得到一个晚上,最终,管理一个线索,这里整洁. 在线调研后,.一致的观点是,,使用开源字体库文泉驿理想的黑色字体效果,效果甚至没有丢失 ...
- Ubuntu 12.04 设置终端字体为文泉驿(转载)
转自:http://my.oschina.net/uniquejava/blog/98480 0.说明 在gnome-terminal终端中看习惯了文泉驿微米黑字体,没想到从11.10升级到 ...
- Centos 下安装 文泉驿 字体 Odoo
刚装完centos下的odoo的字体 文泉驿 ,一万头草泥马呼啸而过.....劝君如非必要,千万别再centos下折腾odoo..... 正题,文泉驿官网 只提供 deb包和源码包的字体安装 ,想在c ...
- Kali安装使用文泉驿字体
安装文泉驿字体 Kali选择"简体中文"安装后,在终端等地方发现字体总有重叠,只要安装中文字体即可,这里推荐文泉驿字体.文泉驿是一个以开发开源.免费中文电子资源--如汉字字体.词库 ...
- QT程序中显示中文字体解决办法
Qt4.7.1 默认没有中文字体库,迅为给用户提供“文泉驿”字体和配置方法.本节需要的 文件在网盘: 用一个简单测试程序说明“文泉驿”字体的配置方法. 在 Qt Creater 新建工程“nihao” ...
- 如何制作prezi swf格式字体(prezi 中文字体)
如何制作prezi swf格式字体(prezi 中文字体) 文/玄魂 前言 Prezi软件虽然没有正式进入中国,但是中国的Prezi爱好者却在不遗余力的推广着Prezi.我接触这款软件比较晚,但是从接 ...
随机推荐
- 分页pagination实现及其应用
1.分页jquery.page.js //分页插件 /** 2014-08-05 ch **/ (function ($) { var ms = { init: function (obj, args ...
- Java学习笔记(六)——google java编程风格指南(下)
[前面的话] 年后开始正式上班,计划着想做很多事情,但是总会有这样那样的打扰,不知道是自己要求太高还是自我的奋斗意识不够?接下来好好加油.好好学学技术,好好学习英语,好好学习做点自己喜欢的事情,趁着自 ...
- 图片百分百问题 z-index问题
遇到的问题: 1.图片设置宽高都为100%,为什么高度没有100%呢? 我日了狗了! 答:因为图片默认高度大于包含框, 此时元素的高度100%将不会参照父元素? 继承出现了问 ...
- RAID 磁盘状态为foreign,怎么变成ready
我们在关掉电源,插入三块硬盘,打开电源 这时候: 首先启动服务器,出现[Press<ctrl><R>to Run Configuration Utility]提示时,按下ctr ...
- Html-input文本框只能输入数字
onKeyPress="if ((event.keyCode < 48 || event.keyCode > 57)) event.returnValue = false;&qu ...
- Spring-如何实现事物管理的
事务的实现方式 实现方式共有两种:编码方式:声明式事务管理方式.基于AOP技术实现的声明式事务管理,实质就是:在方法执行前后进行拦截,然后在目标方法开始之前创建并加入事务,执行完目标方法后根据执行情况 ...
- 【POJ 2923】Relocation(状压DP+DP)
题意是给你n个物品,每次两辆车运,容量分别是c1,c2,求最少运送次数.好像不是很好想,我看了网上的题解才做出来.先用状压DP计算i状态下,第一辆可以运送的重量,用该状态的重量总和-第一辆可以运送的, ...
- 【ZOJ 1221】Risk
题 题意 给你20个城市的相邻关系,求给定任意两个城市的最短距离 分析 求任意两个城市最短距离,就是用floyd算法,我脑残忘记了k是写在最外层的. 代码 #include<stdio.h> ...
- 【BZOJ-2223】PATULJCI 可持久化线段树
2223: [Coci 2009]PATULJCI Time Limit: 10 Sec Memory Limit: 259 MBSubmit: 728 Solved: 292[Submit][S ...
- codevs3031 最富有的人
题目描述 Description 在你的面前有n堆金子,你只能取走其中的两堆,且总价值为这两堆金子的xor值,你想成为最富有的人,你就要有所选择. 输入描述 Input Description 第一行 ...